<?php
/**
 * 管理后台统一入口
 */

// 指定默认模块为Admin 
define('API_NAMESPACE', 'Admin');
define('IADMINOS_PUBLIC_PATH', '/admin');
define('IADMINOS_VERSIOIN', '1.0.0');

// 初始化
require_once dirname(__FILE__) . '/../init.php';

// 模板引擎
$loader = new \Twig\Loader\FilesystemLoader(API_ROOT . '/src/admin/view');
$twig = new \Twig\Environment($loader, [
    'debug' => $di->debug,
    'cache' => API_ROOT . '/runtime/compilation_cache',
]);

// 添加模板函数
$function = new \Twig\TwigFunction('url', function ($path, $params = null) {
    return iadminUrl($path, $params);
});
$twig->addFunction($function);

$di->twig = $twig;

// 错误处理
$di->error = new \Admin\Common\ErrorHandler();

// 页面渲染或接口响应
$pai = new \PhalApi\PhalApi();
$pai->response()->output();


